package com.dubbo.soa.advice;

import com.dubbo.soa.invoke.Invocation;
import com.dubbo.soa.invoke.Invoke;
import com.dubbo.soa.spring.configBean.Reference;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

//增强类
public class InvokeInvocationHandler implements InvocationHandler {
    private Invoke invoke;
    private Reference reference;
    public InvokeInvocationHandler(Invoke Invoke,Reference reference){
        this.reference = reference;
        this.invoke = Invoke;
    }
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("invoke到了这个方法");
        //做一个远程的rpc调用
        Invocation invocation =new Invocation();
        invocation.setIntf(reference.getIntf());
        invocation.setMethod(method);
        invocation.setObjs(args);
        return invoke.invoke(invocation);
    }
}
